package com.huatai.bpmn.utils;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huatai.bpmn.entity.DeployFormMappingEntity;
import com.huatai.bpmn.entity.ExternalParameterEntity;
import com.huatai.bpmn.entity.FileEntity;
import com.huatai.bpmn.service.BasicLoadService;
import com.huatai.bpmn.service.ExternalParameterService;
import com.huatai.bpmn.service.FileService;
import com.huatai.bpmn.service.TbBusinessService;
import com.huatai.common.api.R;
import com.huatai.common.util.AuthUtil;
import org.activiti.engine.*;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipInputStream;

/**
 * @Author: nzj
 * @Date: 2023/7/7 14:11
 */
public class Activiti7Utils {

	private Activiti7Utils(){}

	public static final ProcessEngine PROCESS_ENGINE = ProcessEngines.getDefaultProcessEngine();

	/**
	 * 资源管理类
	 */
	public static final RepositoryService repositoryService = PROCESS_ENGINE.getRepositoryService();

	/**
	 * 运行时管理类
	 */
	public static final RuntimeService runtimeService = PROCESS_ENGINE.getRuntimeService();

	/**
	 * 任务管理类
	 */
	public static final TaskService taskService = PROCESS_ENGINE.getTaskService();

	/**
	 * 历史数据管理类
	 */
	public static final HistoryService historyService = PROCESS_ENGINE.getHistoryService();

	/**
	 * 部署流程
	 * @return
	 */
	/*public boolean createDeployment(MultipartFile file, String deployName){
		//读书文件流
		InputStream inputStream = null;
		try {
			inputStream = file.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
		Deployment deployment = repositoryService.createDeployment()
			.addInputStream(file.getOriginalFilename(), inputStream)
			.name(deployName)
			.deploy();
		//将部署的id和表单进行绑定
		DeployFormMappingEntity deployFormMappingEntity = new DeployFormMappingEntity();
		deployFormMappingEntity.setDeploymentid(deployment.getId());
		deployFormMappingEntity.setExternalParameterId(externalParameterId);
		deployFormMappingService.save(deployFormMappingEntity);

	}*/

	/*public boolean createTask(){
		repositoryService
	}*/
}
